<template>
    <div class="bind_code">
        <div class="title">{{ $t('my.绑定邀请码') }}</div>
        <div class="input_view">
            <el-input v-model="inviteCode" :placeholder="$t('my.请输入邀请码')"></el-input>
        </div>

        <div class="submit" @click="bindCode">{{ $t('my.立即绑定') }}</div>
        <div class="tips">{{ $t('my.注意事项') }}</div>
        <div class="desc">{{ $t('my.输入你获取的邀请码，点击立即绑定后可以绑定邀请人') }}</div>
    </div>
</template>
<script>
export default {
    data() {
        return {
            inviteCode: ""
        }
    },
    methods: {
        async bindCode() {
            if (!this.inviteCode.trim()) {
                uni.showToast({
                    title: this.$t('my.请输入邀请码'),
                    icon: 'none'
                })
                return
            }
            await this.$api.usersApi.bindInviter({
                inviter_code: this.inviteCode
            });
            this.$message({
                message: this.$t('my.绑定成功'),
                type: 'success'
            });
            this.$emit('ok')
        }
    }
}

</script>
<style lang="scss" scoped>
.bind_code {
    width: 544px;
    padding: 32px 24px;
    box-sizing: border-box;
    background: #FFFFFF;
    box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.1);
    border-radius: 4px 4px 4px 4px;
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 2;
    transform: translate(-50%, -50%);

    .title {
        font-weight: bold;
        font-size: 18px;
        color: #333333;
        text-align: center;
    }

    .input_view {
        margin: 24px 0 48px;

        &:deep(.el-input__inner) {
            height: 52px;
            background: #F5F5F5;
        }
    }

    .submit {
        width: 428px;
        height: 52px;
        line-height: 52px;
        text-align: center;
        font-weight: bold;
        font-size: 20px;
        color: #FFFFFF;
        margin: 0 auto;
        background: linear-gradient(270deg, #4488FF 0%, #2BBCFF 100%);
        border-radius: 8px 8px 8px 8px;
        cursor: pointer;
    }

    .tips {
        font-weight: bold;
        font-size: 16px;
        color: #333333;
        margin: 24px 0 8px;
    }

    .desc {
        font-size: 14px;
        color: #333333;
    }
}
</style>